package com.vtc.session4;

import java.util.ArrayList;
import java.util.List;

import com.vtc.session3.Employee;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListView1Adapter extends BaseAdapter{
    private List<Employee> arr;
    private Context context;
	public ListView1Adapter(Context context){
		this.context = context;
		
		arr = new ArrayList<Employee>();
		arr.add(new Employee("Nguyen Van A", "Male", 20));
		arr.add(new Employee("Nguyen B", "Male", 20));
		arr.add(new Employee("Vu Lam", "Male", 20));
		arr.add(new Employee("Hong Ngan", "FeMale", 20));
		arr.add(new Employee("Nguyen Tuan", "Male", 20));
		arr.add(new Employee("Nguyen Van A", "Male", 20));
		arr.add(new Employee("Nguyen Van A", "Male", 20));
		arr.add(new Employee("Nguyen Van A", "Male", 20));
		arr.add(new Employee("Nguyen Van A", "Male", 20));
		arr.add(new Employee("Nguyen B", "Male", 20));
		arr.add(new Employee("Vu Lam", "Male", 20));
		arr.add(new Employee("Hong Ngan", "FeMale", 20));
		arr.add(new Employee("Nguyen Tuan", "Male", 20));
		arr.add(new Employee("Nguyen Van A", "Male", 20));
		arr.add(new Employee("Nguyen Van A", "Male", 20));
		arr.add(new Employee("Nguyen Van A", "Male", 20));
		arr.add(new Employee("Nguyen Van A", "Male", 20));
		arr.add(new Employee("Nguyen B", "Male", 20));
		arr.add(new Employee("Vu Lam", "Male", 20));
		arr.add(new Employee("Hong Ngan", "FeMale", 20));
		arr.add(new Employee("Nguyen Tuan", "Male", 20));
		arr.add(new Employee("Nguyen Van A", "Male", 20));
		arr.add(new Employee("Nguyen Van A", "Male", 20));
		arr.add(new Employee("Nguyen Van A", "Male", 20));
		arr.add(new Employee("Nguyen Van A", "Male", 20));
	}
	@Override
	public int getCount() {		
		return arr.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View v, ViewGroup parent) {
		if(v==null){
			  TextView tvRow = new TextView(context);
			  Employee e = arr.get(position);
			  tvRow.setText(e.getName()+">>"+e.getAge());
			  return tvRow;
		}
		else return v;
	}

}
